/**
 * 
 */
package org.karthik.ecomm.main;

import org.hibernate.Session;
import org.karthik.ecomm.dto.Customer;
import org.karthik.ecomm.dto.Product;
import org.karthik.ecomm.util.HibernateUtil;

/**
 * @author Uday Shankar
 *
 */
public class CustomerArrayListMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		HibernateUtil util = new HibernateUtil();

		Customer customer = new Customer();

		Product product1 = new Product();
		Product product2 = new Product();

		// Product 1
		product1.setProductId(1531);
		product1.setProductName("Surf Excel");
		product1.setProductPrice(98.00);

		// Product 2
		product2.setProductId(1789);
		product2.setProductName("Axe Deodarant");
		product2.setProductPrice(150.00);

		customer.setCustomerName("Manash Kalita");

		// Add the products to the List of products
		customer.getListOfProducts().add(product1);
		customer.getListOfProducts().add(product2);

		Session session = util.getSession();
		session.beginTransaction();

		session.save(customer);
		session.getTransaction().commit();
		session.close();

	}

}
